<?php
namespace app\index\controller;
header("Content-type:text/html;charset=utf-8");

use app\admin\validate\UserRule;
use app\common\controller\Frontend;
use app\common\model\Category;
use think\view\driver\Think;
use app\common\model\App;
use think\Db;

class Search extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {
        $Category=new Category();
        $category=$Category->getCategoryArray();
        $this->assign('category',$category);

        $mod = model('App');
        $cate = $mod->getCateNameList();
        $this->assign('cate', $cate);
//搜索
        $keywords = input('post.keywords');
        $keywords=strip_tags($keywords);
        $result = Db('app')->where('app_name', 'like', "%" . $keywords . "%")->limit(45)->select();
//        var_dump($result);die;
        if (empty($result)) {
            echo "<script>alert('对不起，暂未搜索到相关信息，返回上一页'); window.history.go(-1);</script>";
            die;
        }
        $this->assign('result',$result);
        $this->assign('keywords',$keywords);
        return $this->view->fetch();
    }



}
